<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script type="text/javascript" src="fabric.js" ></script>
    <script type="text/javascript" src="rgbbaster.js"></script>
    <script src="jquery.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="qrcode.js"></script>
    <script src="base64.min.js"></script>
    <script src="canvas2image.js"></script>

</head>
<body>
    <div style="float: left">
        <div id="qrcode"></div>
    </div>
</body>
<script>
    //下载图片
    function download(){
        downloadFile('qrcode.png', canvas.toDataURL("image/png"));
    }

    function downloadFile(fileName, content){
        var save_link = document.createElementNS('http://www.w3.org/1999/xhtml', 'a');
        save_link.href = content;
        save_link.download = fileName;
        var event = document.createEvent('MouseEvents');
        event.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
        save_link.dispatchEvent(event);
    }

    window.onload = function(){
        $('#qrcode').qrcode({
            foreground: 'black',
            width: 51, 
            height: 51,
            correctLevel: QRErrorCorrectLevel.L,
            text: 'https://m',
        });
    }
</script>
</html>